<template>
	<view class="page-container">
		<!-- 公共导航栏 -->
		<public-module leftIcon="arrow-left" title="岗位详情" />
		
		<!-- 内容区域 -->
		<view class="content-wrapper">
			<view class="detail-content">
				<!-- 岗位标题 -->
				<view class="job-header">
					<view class="job-title">{{ jobDetail.positionName }}</view>
					<view class="job-badge">{{ jobDetail.affiliation }}</view>
				</view>
				
				<!-- 基本信息卡片 -->
				<view class="info-card">
					<view class="card-title">
						<u-icon name="info-circle" size="18" color="#4A89DC"></u-icon>
						<text>基本信息</text>
					</view>
					<view class="info-row">
						<text class="label">招录年份：</text>
						<text class="value">{{ jobDetail.recruitmentYear }}</text>
					</view>
					<view class="info-row">
						<text class="label">所属地区：</text>
						<text class="value">{{ jobDetail.areaName }}</text>
					</view>
					<view class="info-row">
						<text class="label">招录单位：</text>
						<text class="value">{{ jobDetail.unitName }}</text>
					</view>
					<view class="info-row">
						<text class="label">岗位类别：</text>
						<text class="value">{{ jobDetail.positionCategory }}</text>
					</view>
				</view>
				
				<!-- 岗位介绍卡片 -->
				<view class="info-card" v-if="jobDetail.positionIntro">
					<view class="card-title">
						<u-icon name="file-text" size="18" color="#4A89DC"></u-icon>
						<text>岗位介绍</text>
					</view>
					<view class="intro-text">{{ jobDetail.positionIntro || '暂无介绍' }}</view>
				</view>
				
				<!-- 任职要求卡片 -->
				<view class="info-card">
					<view class="card-title">
						<u-icon name="checkmark-circle" size="18" color="#4A89DC"></u-icon>
						<text>任职要求</text>
					</view>
					<view class="info-row">
						<text class="label">学历要求：</text>
						<text class="value highlight">{{ jobDetail.education }}</text>
					</view>
					<view class="info-row">
						<text class="label">专业要求：</text>
						<text class="value highlight">{{ jobDetail.major }}</text>
					</view>
					<view class="info-row" v-if="jobDetail.otherRequirements">
						<text class="label">其他要求：</text>
						<text class="value">{{ jobDetail.otherRequirements }}</text>
					</view>
				</view>
				
				<!-- 竞争情况卡片 -->
				<view class="info-card">
					<view class="card-title">
						<text class="emoji-icon">📊</text>
						<text>竞争情况</text>
					</view>
					<view class="stats-grid">
						<view class="stat-box">
							<text class="stat-label">招录人数</text>
							<text class="stat-value">{{ jobDetail.recruitmentNumbers }}</text>
						</view>
						<view class="stat-box">
							<text class="stat-label">报名人数</text>
							<text class="stat-value hot">{{ jobDetail.applicationNumbers }}</text>
						</view>
						<view class="stat-box">
							<text class="stat-label">竞争比例</text>
							<text class="stat-value">{{ jobDetail.applicationRatio }}</text>
						</view>
						<view class="stat-box">
							<text class="stat-label">考试比例</text>
							<text class="stat-value">1:{{ jobDetail.examinationRatio }}</text>
						</view>
					</view>
				</view>
				
				<!-- 面试分数卡片 -->
				<view class="info-card" v-if="jobDetail.minimumInterviewScore">
					<view class="card-title">
						<u-icon name="edit-pen" size="18" color="#4A89DC"></u-icon>
						<text>进面成绩</text>
					</view>
					<view class="score-grid">
						<view class="score-item">
							<text class="score-label">最低分</text>
							<text class="score-value">{{ jobDetail.minimumInterviewScore }}</text>
						</view>
						<view class="score-item">
							<text class="score-label">最高分</text>
							<text class="score-value">{{ jobDetail.maximumInterviewScore }}</text>
						</view>
						<view class="score-item">
							<text class="score-label">平均分</text>
							<text class="score-value">{{ jobDetail.averageInterviewScore }}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				jobDetail: {}
			}
		},
		onLoad(options) {
			// 从URL参数中获取岗位数据
			if (options.job) {
				try {
					this.jobDetail = JSON.parse(decodeURIComponent(options.job));
				} catch (err) {
					console.error('解析岗位数据失败:', err);
					uni.showToast({
						title: '数据加载失败',
						icon: 'none'
					});
					setTimeout(() => {
						uni.navigateBack();
					}, 1500);
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	/* 页面容器 */
	.page-container {
		width: 100%;
		min-height: 100vh;
		background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
	}
	
	/* 内容包裹器 */
	.content-wrapper {
		width: 100%;
		min-height: 100vh;
		box-sizing: border-box;
	}
	
	/* 详情内容 */
	.detail-content {
		padding: 20rpx;
	}
	
	/* 岗位标题 */
	.job-header {
		background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
		padding: 40rpx 30rpx;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 8rpx 20rpx rgba(102, 126, 234, 0.3);
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.job-title {
		font-size: 36rpx;
		font-weight: bold;
		color: #fff;
		flex: 1;
		line-height: 1.4;
	}
	
	.job-badge {
		background-color: rgba(255, 255, 255, 0.25);
		color: #fff;
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		font-size: 24rpx;
		margin-left: 15rpx;
		backdrop-filter: blur(10rpx);
		border: 1rpx solid rgba(255, 255, 255, 0.3);
	}
	
	/* 信息卡片 */
	.info-card {
		background-color: #fff;
		border-radius: 20rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06);
		animation: slideUp 0.4s ease;
	}
	
	@keyframes slideUp {
		from {
			opacity: 0;
			transform: translateY(30rpx);
		}
		to {
			opacity: 1;
			transform: translateY(0);
		}
	}
	
	.card-title {
		display: flex;
		align-items: center;
		gap: 10rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 25rpx;
		padding-bottom: 15rpx;
		border-bottom: 2rpx solid #f0f0f0;
	}
	
	.emoji-icon {
		font-size: 36rpx;
		line-height: 1;
	}
	
	/* 信息行 */
	.info-row {
		display: flex;
		margin-bottom: 20rpx;
		line-height: 1.8;
	}
	
	.info-row:last-child {
		margin-bottom: 0;
	}
	
	.label {
		font-size: 28rpx;
		color: #666;
		min-width: 180rpx;
	}
	
	.value {
		font-size: 28rpx;
		color: #333;
		flex: 1;
		word-break: break-all;
	}
	
	.value.highlight {
		color: #4A89DC;
		font-weight: 500;
	}
	
	/* 岗位介绍 */
	.intro-text {
		font-size: 28rpx;
		color: #666;
		line-height: 1.8;
		text-align: justify;
	}
	
	/* 统计数据网格 */
	.stats-grid {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 20rpx;
	}
	
	.stat-box {
		background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
		padding: 25rpx;
		border-radius: 15rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 15rpx;
		border: 1rpx solid #e0e0e0;
	}
	
	.stat-label {
		font-size: 24rpx;
		color: #999;
	}
	
	.stat-value {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
	}
	
	.stat-value.hot {
		color: #FF6B6B;
	}
	
	/* 分数网格 */
	.score-grid {
		display: flex;
		justify-content: space-around;
		gap: 15rpx;
	}
	
	.score-item {
		flex: 1;
		background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
		padding: 25rpx 15rpx;
		border-radius: 15rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		gap: 10rpx;
		box-shadow: 0 4rpx 12rpx rgba(102, 126, 234, 0.2);
	}
	
	.score-label {
		font-size: 24rpx;
		color: rgba(255, 255, 255, 0.9);
	}
	
	.score-value {
		font-size: 34rpx;
		font-weight: bold;
		color: #fff;
	}
</style>
